<template>
  <el-dialog :append-to-body="true" :visible.sync="visible" v-dialogDrag :title="title" :close-on-click-modal="false" class="tl-dialog page" width="1200px" @open="open" @close="close">
    <el-form class="tl-form stakeholderForm" ref="form" :model="model" :rules="rules" label-width="300px" :disabled="true">
			<el-row>
				<el-col :span="24">
					<el-form-item label="评分项目（大类）" prop="scoringitem_big_catergory" :rules="rules.validateRequire">
						<el-input v-model="model.scoringitem_big_catergory"></el-input>
					</el-form-item>
				</el-col>
			</el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="评分项目（小类）" prop="scoringitem_small_catergory">
            <el-input v-model="model.scoringitem_small_catergory" ></el-input>
          </el-form-item>
        </el-col>
      </el-row>
			<el-row>
				<el-col :span="24">
					<el-form-item label="评分细则" prop="scoringrubric" :rules="rules.validateRequire">
						<el-input v-model="model.scoringrubric" type="textarea" :rows="3"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label="细则描述" prop="scoredescription">
						<el-input v-model="model.scoredescription" type="textarea" :rows="3"></el-input>
					</el-form-item>
				</el-col>
			</el-row>
			<el-row>
				<el-col :span="12">
					<el-form-item label="满分" prop="fullscore" :rules="rules.validateRequire">
						<el-input v-model="model.fullscore" type="number"  oninput="this.value=this.value.match(/\d{0,}\.?\d{0,1}/)"></el-input>
						<span class="unitSpan">分</span>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="自评分" prop="selfscore" :rules="rules.validateRequire">
						<el-input v-model="model.selfscore" type="number"  oninput="this.value=this.value.match(/\d{0,}\.?\d{0,1}/)"></el-input>
						<span class="unitSpan">分</span>
					</el-form-item>
				</el-col>
			</el-row>
			<el-row>
				<el-col :span="12">
					<el-form-item label="目标得分" prop="targetscore" :rules="rules.validateRequire">
						<el-input v-model="model.targetscore" type="number"></el-input>
						<span class="unitSpan">分</span>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="分差" prop="scoregap" :rules="rules.validateRequire">
						<el-input v-model="model.scoregap" :disabled="true"></el-input>
						<span class="unitSpan">分</span>
					</el-form-item>
				</el-col>
			</el-row>
			<el-row>
				<el-col :span="24">
					<el-form-item label="基于专家意见的差距分析" prop="gapanalysis" :rules="rules.validateRequire">
						<el-input v-model="model.gapanalysis" type="textarea" show-word-limit maxlength="1000" :rows="3"></el-input>
					</el-form-item>
				</el-col>
			</el-row>
			<el-row>
				<el-col :span="24">
					<el-form-item label="提分计划" prop="scoringplan" :rules="rules.validateRequire">
						<el-input v-model="model.scoringplan" type="textarea" show-word-limit maxlength="1000" :rows="3"></el-input>
					</el-form-item>
				</el-col>
			</el-row>
			<el-row>
				<el-col :span="12">
					<el-form-item label="责任人" prop="responsible" :rules="rules.validateRequire">
						<tl-ref-stakeholder v-model="model.responsible" :initDisplayData.sync="model.responsible" fieldKey="usercode" :externalSelectedRowKeys="model.responsiblecode" title="选择责任人" :externalQueryParam="externalQueryParam" :isSingleSelect="true"></tl-ref-stakeholder>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="计划完成日期" prop="planenddate" :rules="rules.validateRequire">
						<el-date-picker v-model="model.planenddate" type="date" :picker-options="pickerOptions" placeholder="计划完成日期" value-format="yyyy-MM-dd"></el-date-picker>
					</el-form-item>
				</el-col>
			</el-row>
    </el-form>
	<el-form class="tl-form stakeholderForm" ref="form1" :model="model" :rules="rules" label-width="300px">
			<el-row>
				<el-col :span="12">
					<el-form-item label="本周提升分数" prop="improvescore" >
						<el-input v-model="model.improvescore" @change="changescore" oninput="this.value=this.value.match(/\d{0,}\.?\d{0,1}/)"></el-input>
						<span class="unitSpan">分</span>
					</el-form-item>
				</el-col>
			</el-row>
	</el-form>
    <tl-approval-history ref="history" sourceType="MpmProjectBidScore" :sourceId="model.id" />
    <div slot="footer" class="dialog-footer">
      <el-button :type="disableEditSubmit === false ? 'text' : 'primary'" @click="doCancelEdit">取消</el-button>
      <el-button type="primary" @click="doSubmitEdit" :loading="saveLoading" v-if="!disableEditSubmit"><svg-icon icon-class="save" />暂存</el-button>
      <el-button type="primary" @click="dosave" :loading="saveLoading" v-if="!disableEditSubmit"><svg-icon icon-class="send" />提交</el-button>
    </div>
  </el-dialog>
</template>

<script>
/** mixins */
import { mixin_approval_edit } from '@tapui/mixins/mixin_approval_edit'
/** 子组件 */
import TlRefStakeholder from '../mpmProjectStakeholder/refList'
/** 工具类 */
import { putAction, getAction, postAction, deleteAction } from '@tapui/utils/http'
/** VUE配置 */
export default {
  mixins: [mixin_approval_edit],
  components: { TlRefStakeholder },
  data() {
    return {
      moduleTitle: '本周提升分数',
      urlPrefix: '/mpm/projectBidScore/',
      url: {
        // 额外的url
		queryMpmInfo: '/mpm/projectBidScore/queryMpmInfo/'
      },
      externalQueryParam: {
        qry_projectcode: this.projectinfo.projectcode // 项目编号
      },
      pickerOptions: {
        disabledDate: time => {
            return time.getTime() > this.biddate.getTime()
        }
      },
      title: '本周提升分数',
      type: '1',
      times: '1'
    }
  },
  props: {
    projectinfo: {},
    biddate: {
      type: Date,
      default: new Date()
    }
  },
  methods: {
	dosave() {
		this.$tap.confirm('确定提交吗？提交后将计入本周提升分数合计！').then(_ => {
          this.model.actualenddate = new Date()
          this.$set(this.model, 'isChange', true)
          this.doSubmitEdit()
          this.$emit('refresh')
          this.visible = false
        })
        .catch(_ => {
          this.submitLoading = false
        })
	},
	changescore() {
		let fullscore = parseFloat(this.model.fullscore ? this.model.fullscore : 0)
		let improvescore = parseFloat(this.model.improvescore ? this.model.improvescore : 0)
		if (fullscore < improvescore) {
			this.$tap.alert('提升分数不能大于满分！')
			this.$set(this.model, 'improvescore', 0)
			return
		}
	}
  }
}
</script>
<style scoped lang="scss">
.stakeholderForm {
  margin-top: 15px;
  margin-left: -220px;
  .el-row {
    margin-bottom: 2px;
  }
  /* 隐藏禁用状态下的提示 */
  .is-disabled ::placeholder {
    color: transparent !important;
  }
}
.tl-ref-user {
  /deep/ .tl-ref-selector {
    .el-button {
      background-color: red !important;
    }
  }
}
</style>
